package correct.day16;

import java.util.Scanner;

public class Test333 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] arr = in.next().toCharArray();
        int x = in.nextInt();
        int count = 0;
        int maxCount = 0;
        int index = 0;
        int left = 0, right = 0;
        int len = arr.length;
        while(right < len) {
            if(arr[right] == 'C' || arr[right] == 'G') {
                count++;
            }
            if(right - left + 1 > x) {
                if (arr[left] == 'C' || arr[left] == 'G') {
                    count--;
                }
                left++;
            }
            if(right - left + 1 == x) {
                if(count > maxCount) {
                    maxCount = count;
                    index = left;
                }
            }
            right++;
        }
        for(int i = 0; i < x; i++) {
            System.out.print(arr[i+index]);
        }
    }
}
